<script setup>
import {ref} from "vue";
import http from "@/utils/http.js";
import router from "@/router/index.js";

const QuestionList = ref([])

//aid-文章id
const getQuestionContent = async (aid) =>{
  try{
    const response = await http.get(`/expert/expertQuestion/148`)
    QuestionList.value = response.data
    QuestionList.value=QuestionList.value.slice(0,4)
    console.log(response)
  }catch (error){
    console.error('获取文章内容失败:',error)
  }
}
getQuestionContent()

</script>

<template>
  <el-card class="qa-card" shadow="hover">
    <div v-for="item in QuestionList" :key="item.qid" class="QAcard" @click="router.push(`/question/${item.qid}`)">
      <div class="question">
        <el-badge value="问" color="#14c131"></el-badge>
        <span>{{ item.user_ques }}</span>
      </div>
      <div class="answer">
        <el-badge value="答" color="#ff862c"></el-badge>
        <span>{{ item.expert_ans }}</span>
      </div>
      <div class="footer">
        <span style="float: left">全部{{ item.adoptNumbers }}个回答</span>
        <span style="float: right">{{ item.expert_date.split(' ')[0] }}</span>
      </div>
    </div>
  </el-card>
</template>

<style scoped lang="less">
.qa-card {
  width: 100%;
  height: auto;
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
}

.QAcard{
  width: 100%;
  height: auto;
  min-height: 100px;
  margin-top: 1px;
  margin-bottom: 1px;
  padding: 5px;
  border-radius: 5px;
  //transition: transform .2s, box-shadow .2s;
}

.QAcard:hover{
  transition: transform .2s, box-shadow .2s;
  transform: translateY(-4px);
  box-shadow: 4px 4px 8px rgba(0, 0, 0, .1), -4px -4px 8px rgba(0, 0, 0, .1);
  cursor: pointer; //光标变成手
}

.question{
  margin-top: 5px;
  font-size: 12px;
  height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question:hover{
  color:#14c131
}

.answer{
  font-size: 12px;
  height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer{
  margin-top: 3px;
  margin-left: 5px;
  font-size: 12px;
  height: 10px;
  color: #909090;
}
</style>